let data;

window.exports = {
    "emoticon": {
        mode: "list",
        args: {
            //{"name":"a","keyWord":"a(>_<)","paste":"(>_<)"}
            enter: (action, callbackSetList) => {
                if (!data) {
                    console.log('init emojis_code')
                    data = require('./data.json')
                }

                callbackSetList(data.map(({name, keyWord, paste}) => {
                    return {
                        title: name,
                        description: paste,
                        icon: ''
                    }
                }))
                // callbackSetList([
                //     {
                //         title: '这是标题',
                //         description: '这是描述',
                //         icon:''
                //     }
                // ])
            },
            search: (action, searchWord, callbackSetList) => {
                console.log(action,searchWord)
                callbackSetList(data.filter(({keyWord})=> {
                    return keyWord.includes(searchWord)
                }).map(({name, paste}) => {
                    return {
                        title: name,
                        description: paste,
                        paste: paste
                    }
                }))
                // callbackSetList([
                //     {
                //         title: '这是标题',
                //         description: '这是描述',
                //         icon: '', // 图标
                //         url: 'https://yuanliao.info'
                //     }
                // ])
            },
            select: (action, itemData, callbackSetList) => {
                utools.copyText(itemData.paste);
                utools.hideMainWindow(true);
            },
            placeholder: "搜索"
        }
    }
}